<?php

namespace App\Http\Controllers\V1;

use App\Service\ProductService;
use Betterde\Tree\Generator;
use App\Http\Controllers\Controller;

class CategroyController extends Controller
{
    /**
     * 分类首页
     * @param ProductService $productService
     * @return mixed
     * @throws \Betterde\Tree\Exceptions\TreeException
     */
    public function index(ProductService $productService)
    {
        $assort = $productService->getProductCategory();

        $generator = new Generator();

        $tree = $generator->make($assort);

        return $this->success($tree);
    }

    public function getChildrenCate(ProductService $productService)
    {
        $category = $productService->getProductTwoCate();

        return $this->success($category);
    }
}
